import * as Types from 'containers/ActionTypes';

export default function (state = {}, action) {
  var likesCount;
  switch (action.type) {
  case Types.MY.LIKES.UPDATE_MY_LIKES_COUNT:
    return Object.assign({}, state, {
      likesCount: action.totalCount,
    });
  case Types.WORK.UPDATE_LIKE_SUCCESS:
    likesCount = state.likesCount || 0;
    return Object.assign({}, state, {
      likesCount: likesCount + 1,
    });
  case Types.WORK.UPDATE_UNLIKE_SUCCESS:
    likesCount = state.likesCount || 0;
    return Object.assign({}, state, {
      likesCount: likesCount - 1,
    });
  default:
    return state;
  }
}
